<?php

namespace app\common\model;;

// use think\Model;

class TranslateModel extends BaseModel{

	protected $table = 'tp_translate';

	/*
	添加记录
	 */
	public function addData($str_md5,$str,$lang,$t_str){
		if ($lang == 'yn') {
			$lang = 'idd';
		}
		$data = $this->where('str_md5',$str_md5)->find();
		if($data){
			$res = $this->where('id',$data['id'])->update([
				$lang=>$t_str
			]);
		} else {
			$res = $this->insert([
				'zh'=>$str,
				'str_md5'=>$str_md5,
				$lang=>$t_str
			]);
		}
		return $res;
	}

	/*
	
	 */
	public function getTranslate($str_md5,$lang){
		if ($lang == 'yn') {
			$lang = 'idd';
		}
		$data = $this->where('str_md5',$str_md5)->value($lang)?:'';
		return $data;
	}
}